﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NamingOnLessonEntity;
using System.Reflection;

namespace NamingOnLesson
{
    public partial class MainForm : Form
    {
        public User user = new User();
        public User GetUser()
        {
            return user;
        }
        public void SetUser(User user)
        {
            this.user = user;
        }
        public MainForm()
        {
            InitializeComponent();
            initMenu();

        }
        void initMenu()
        {
            if (string.IsNullOrEmpty(user.Name))
            {
                DialogResult dr = OpenForm("", ".LoginForm");
                if (dr == DialogResult.OK)
                {

                }
                else
                {
                    Application.Exit();
                }
            }
            int type = this.user.UserType;

        }
        public DialogResult OpenForm(string entityName, string action)
        {
            Type type = Assembly.Load("NamingOnLesson" + entityName).GetType("NamingOnLesson" + entityName + action);
            Form form = Activator.CreateInstance(type) as Form;
            //form.Show();
            var dr_result = form.ShowDialog(this);
            return dr_result;
        }
    }
}
